package StudyCode.summary.myfile;

import java.nio.file.FileSystems;
import java.nio.file.Path;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CreatePathObjectAndUnderstand {
	public static void main(String[] args) {
		Path path = FileSystems.getDefault().getPath("/home/docs/status.txt");
		System.out.println();
		System.out.printf("toString: %s\n", path.toString());
		System.out.printf("文件名: %s\n", path.getFileName());
		System.out.printf("根节点: %s\n", path.getRoot());
		System.out.printf("各级别目录数量: %d\n", path.getNameCount());
		for (int index = 0; index < path.getNameCount(); index++) {
			System.out.printf("名称(%d): %s\n", index, path.getName(index));
		}
		System.out.printf("subpath(0,2): %s\n", path.subpath(0, 2));
		System.out.printf("父目录: %s\n", path.getParent());
		System.out.println(path.isAbsolute());

		path = FileSystems.getDefault().getPath("\\home\\docs\\status.txt");
	}
}
